home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6781 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: solon.com!not-for-mail
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated,comp.os.ms-windows.programmer.misc
  4. Subject: Re: Text representation of a number...
  5. Date: 14 Feb 1996 21:06:12 -0600
  6. Organization: CERN European Lab for Particle Physics
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4fu7v4$9c4@solutions.solon.com>
  10. References: <4fjm7r$odb@solutions.solon.com> <4fst12$2a9@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12. X-Newsreader: NN version 6.5.0 #7 (NOV)
  13.  
  14. In <4fst12$2a9@solutions.solon.com> news@rose.com (news) writes:
  15.  
  16. >In article <4fjm7r$odb@solutions.solon.com>,
  17. >Joel York <yorkjoe@elof.acc.iit.edu> wrote:
  18. >>
  19. >>I'm in need of an algorithm to take an eight-byte integer (not supported
  20. >>as a native type in Windows 3.1), and print its ASCII representation
  21. >>to a file.  This number comes from a server that stores the number in
  22. >>big-endian format, but I could switch it if necessary.  If anyone
  23. >
  24. >read the number into an array of 8 chars
  25. >using binary shifts, re-create the number into an unsigned long int
  26. >fprintf to file using %lu
  27.  
  28. Do people actually _think_ before posting "solutions"?
  29.  
  30. How the hell can you fit a 64-bit integer into a 32-bit unsigned long,
  31. using binary shifts?  People working in the data compression field would
  32. _love_ to find the answer :-)
  33.  
  34. [1.  Remove all zeroes.  They don't carry any voltage anyway.  2.  Count the
  35.  ones.  You have no more than 64.  Any number < 64 can be easily fit in
  36.  an unsigned long.  Sheesh, doesn't anyone *think* anymore? -mod]
  37.  
  38. [I leave uncompression as an exercise for God. -mod]
  39.  
  40. Dan
  41. --
  42. Dan Pop
  43. CERN, CN Division
  44. Email: danpop@mail.cern.ch 
  45. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  46.